﻿namespace FlexField.Metadata.EntityFrameworkCore
{
    /// <summary>
    /// Represents a field in the metadata system.
    /// </summary>
    /// <typeparam name="TKey">The type used for the primary key for the field.</typeparam>
    public class DataField<TKey> where TKey : IEquatable<TKey>
    {
        /// <summary>
        /// Gets or sets the primary key for this data field.
        /// </summary>
        public virtual TKey Id { get; set; }

        /// <summary>
        /// Gets or sets the entity primary key that this data field belongs to.
        /// </summary>
        public virtual TKey EntityId { get; set; }

        /// <summary>
        /// Gets or sets the type code of this data field.
        /// </summary>
        public virtual string ValueType { get; set; }

        /// <summary>
        /// Gets or sets the name of this data field.
        /// </summary>
        public virtual string FieldName { get; set; }

        /// <summary>
        /// Gets or sets the normalized name for this field.
        /// </summary>
        public virtual string NormalizedFieldName { get; set; }

        /// <summary>
        /// Gets or sets the display name of this data field.
        /// </summary>
        public virtual string DisplayName { get; set; }

        /// <summary>
        /// A random value that must change whenever a field is persisted to the store
        /// </summary>
        public virtual string ConcurrencyStamp { get; set; }

        /// <summary>
        /// Gets or sets the related field property entities.
        /// </summary>
        public virtual ICollection<DataFieldProperty<TKey>> Properties { get; set; }

        public override string ToString()
        {
            return FieldName;
        }
    }
}